package edu.sctu.wangfuxin.day20150609;

import edu.sctu.wangfuxin.day20150609.appbean.PeopleAppbean;
import edu.sctu.wangfuxin.day20150609.data.SetPeopleData;
import edu.sctu.wangfuxin.day20150609.data.SetTrainData;
import edu.sctu.wangfuxin.day20150609.util.BaoGuoDeth;
import edu.sctu.wangfuxin.day20150609.util.CardDeth;

import java.util.List;

/**
 * Created by user06 on 2015/6/10.
 */
public class Datautil {
    private String weijin = "adad";
    private SetTrainData settraindata;
    private SetPeopleData people;

    public Datautil() {
        settraindata = new SetTrainData();
        people = new SetPeopleData();
    }

    public void getPeople() {
        List<PeopleAppbean> list = people.setPeopleData();
        for (PeopleAppbean people : list) {
            if (people.isIs_card()) {
                String problem = chaBaoGuo(people);
                System.out.println(problem);
                if (problem.contains("??")) {
                    kouPrice(people);
                }
            } else {

            }
        }
    }


    public String chaBaoGuo(PeopleAppbean people) {
        BaoGuoDeth baoguodeth = new BaoGuoDeth(people, weijin);
        if (baoguodeth.chaBaoGuo()) {
            return "??????????";
        } else {
            return chaWater(people);
        }
    }


    public String chaWater(PeopleAppbean people) {
        BaoGuoDeth baoguodeth = new BaoGuoDeth(people, weijin);
        if (baoguodeth.chaWater()) {
            return "???????";
        } else {
            ifPrice(people);
            return "????????";
        }
    }


    public void ifPrice(PeopleAppbean people) {
        if (people.getPice() > 2) {
            System.out.println("???");
        } else {
            new CardDeth().setPrice(10, people);
            System.out.println("??????");
            ifPrice(people);
        }

    }

    public void kouPrice(PeopleAppbean people) {

        CardDeth cardeth = new CardDeth(settraindata.setHashMapData());
        if (people.getPice() >= cardeth.getPrice(people.getStart(),
                people.getEnd())) {
            System.out.println("???,????:"+ (people.getPice() - cardeth.getPrice(people.getStart(),
                    people.getEnd())));
        } else {
            cardeth.setPrice(10, people);
            System.out.println("??????");
            kouPrice(people);
        }
    }
}

